using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using MovieDB.Common;

namespace MovieDB.Models
{
    public class MovieModel
    {
        public Guid Id { get; set; }
        public string CreatedAt { get; set; }

        [Required(AllowEmptyStrings = false)]
        [Remote("IsTitleAvailable", "Movie", ErrorMessage = "Title already exists.")]
        public string Title { get; set; }

        [Required(AllowEmptyStrings = false)]
        public string Location { get; set; }
        public MovieGenre Genre { get; set; }
        public VideoQualityModel VideoQuality { get; set; }
        public IList<AudioQualityModel> AudioQualities { get; set; }
        public ModelCRUDType Type { get; set; }

        public string AudioQualitiesAsString { get; set; }
        public string VideoQualitiesAsString { get; set; }
        public string MovieGenreAsString { get; set; }


        public IEnumerable<SelectListItem> MovieGenreForDropDownBox
        {
            get { return EnumToSelectItemConversion.GetSelectListItem<MovieGenre>(Genre); }
        }

        public IEnumerable<SelectListItem> VideoTypeForDropDownBox
        {
            get { return EnumToSelectItemConversion.GetSelectListItem<VideoType>(VideoQuality.VideoType); }
        }

        public IEnumerable<SelectListItem> VideoResolutionForDropDownBox
        {
            get { return EnumToSelectItemConversion.GetSelectListItem<VideoResolution>(VideoQuality.VideoResolution); }
        }

        public IEnumerable<SelectListItem> GetAudioTypeForDropDownBox(AudioQualityModel audioQualityModel)
        {
            if (audioQualityModel == null)
            {
                throw new ArgumentNullException("audioQualityModel");
            }

            return EnumToSelectItemConversion.GetSelectListItem<AudioType>(audioQualityModel.AudioType);
        }

        public IEnumerable<SelectListItem> GetAudioChannelsForDropDownBox(AudioQualityModel audioQualityModel)
        {
            if (audioQualityModel == null)
            {
                throw new ArgumentNullException("audioQualityModel");
            }
            return EnumToSelectItemConversion.GetSelectListItem<AudioChannels>(audioQualityModel.AudioChannels);
        }
    }
}